package lelouet.sh3d.plugins.sweetDatacenter;

import gridlib.api.MachineModel;

import java.rmi.RemoteException;

import lelouet.sh3d.plugins.sweetDatacenter.model.GElementFactory;

import com.eteks.sweethome3d.plugin.PluginAction;

public class CreateModelButton extends PluginAction {

	SweetDatacenterPlugin parent;
	GElementFactory bridge;

	@Override
	public void execute() {
		MachineModel model = bridge.generateModel();
		try {
			System.out.println("created model " + model.getName());
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		parent.addModel(model);
	}

	public CreateModelButton(SweetDatacenterPlugin parent,
			GElementFactory bridge) {
		super("lelouet.sh3d.plugins.sweetDatacenter.ApplicationPlugin",
				"CREATE_MODEL", parent.getPluginClassLoader(), true);
		this.parent = parent;
		this.bridge = bridge;
	}

}